//
//  HomeCollectionViewCell.m
//  QXShowing
//
//  Created by 王道道 on 2018/4/24.
//  Copyright © 2018年 doll_dream. All rights reserved.
//

#import "HomeCollectionViewCell.h"

//#define kHomeCellWidth ((App_Frame_Width-3*20)/2)

@implementation HomeCollectionViewCell

- (id)initWithFrame:(CGRect)frame {
    if (self = [super initWithFrame:frame]) {
        [self setUpUI];
        [self _viewLayout];
    }
    return self;
}

- (id)init {
    if (self = [super init]) {
    }
    return self;
}

- (void)setUpUI {
    self.contentView.backgroundColor = Main_BackColor;
//    self.layer.shadowColor = [UIColor blackColor].CGColor;
//    self.layer.shadowOpacity = 0.1;
    
//    self.imageView = [[UIImageView alloc]init];
//    self.imageView.contentMode = UIViewContentModeScaleAspectFill;
//    self.imageView.clipsToBounds = YES;
//    self.imageView.backgroundColor = Main_BackColor;
//    [self.contentView addSubview:self.imageView];
    
    self.homeImage = [[UIImageView alloc]init];
    self.homeImage.clipsToBounds = YES;
    self.homeImage.layer.cornerRadius = 15;
//    self.homeImage.layer.borderWidth = BHBorder_Width * 5.f;
//    self.homeImage.layer.borderColor = [UIColor whiteColor].CGColor;
    self.homeImage.image = [UIImage imageNamed:@"home-1"];
    [self.contentView addSubview:self.homeImage];
    
    self.titleLabel = [[UILabel alloc]init];
    self.titleLabel.textColor = Text_Color_FFFFFF;
    self.titleLabel.font = BHFont_Size_22;
    self.titleLabel.textAlignment = NSTextAlignmentCenter;
    self.titleLabel.numberOfLines = 0;
//    self.titleLabel.backgroundColor = Bg_Color_333333;
//    self.titleLabel.alpha = 0.2;
    self.titleLabel.backgroundColor = [UIColor clearColor];
    [self.contentView addSubview:self.titleLabel];
}

- (void)_viewLayout {
    [self.homeImage mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.equalTo(self.contentView);
        make.centerX.equalTo(self.contentView);
        make.centerY.equalTo(self.contentView);
    }];
   
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.height.width.equalTo(self.contentView);
        make.centerX.equalTo(self.contentView);
        make.centerY.equalTo(self.contentView);
    }];
}

- (void)setModel:(HomeShowListModel *)model {
    if (![BHSettingUtil dataAndStringIsNull:model]) {
        _model = model;
        if (![BHSettingUtil dataAndStringIsNull:model.pic]) {
            [self.homeImage sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@", BH_PicPreString, model.pic]] placeholderImage:[UIImage imageNamed:@"home-1"]];
        }
        self.titleLabel.text = [BHSettingUtil dataAndStringIsNull:model.title]?@"":model.title;
    }
}

@end
